﻿using GENERIC.MVVM.Interfaces.View;
using GENERIC.MVVM.Interfaces.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GENERIC.MVVM
{
    public class ModalDialogService : IModalDialogService
    {
        public void ShowDialog<TViewModel>(IModalFormView view, TViewModel viewModel, Action<TViewModel> onDialogClose)
        {
            view.DataContext = viewModel;
            if (onDialogClose != null)
            {
                view.Closed += (sender, e) => onDialogClose(viewModel);
            }
            view.Show();
        }

        public void ShowDialog<TDialogViewModel>(IModalFormView view, TDialogViewModel viewModel)
        {
            this.ShowDialog(view, viewModel, null);
        }
    }
}
